﻿using System.Collections.Generic;
using MRGSP.SurveyMaster.Core;
using MRGSP.SurveyMaster.Core.Model;
using MRGSP.SurveyMaster.Core.Service;
using MRGSP.SurveyMaster.Core.Service.Utils;

namespace MRGSP.SurveyMaster.Service.Utils
{
    public class HtmlGeneratorFactory
    {
        private static readonly IDictionary<ControlType, IHtmlGenerator> Generators = new Dictionary<ControlType, IHtmlGenerator>
                                                                                     {
                                                                                         {ControlType.Radio, new RadioGenerator()},
                                                                                         {ControlType.Checkbox, new CheckBoxGenerator()},
                                                                                         {ControlType.Textbox, new TextBoxGenerator()},
                                                                                         {ControlType.TextArea, new TextAreaGenerator()},
                                                                                         {ControlType.Header, new HeaderGenerator()},
                                                                                         {ControlType.Grid, new HeaderGenerator()},
                                                                                         {ControlType.GridColumn, new HeaderGenerator()},
                                                                                     };
               
        public static IHtmlGenerator Get(ControlType type)
        {
            return Generators[type];
        }

        public static string Generate(Question question)
        {
            return Get(question.Type).Generate(question);
        }
    }
}